Sub SendMailPdf()
On Error Resume Next
Dim def As String
Dim CAJA As String
Dim ImpresoraAUsar As String
Dim ObjNetWork As Object
Dim Impresora As String
Dim OA, OM As Object
Dim NA As Variant
Dim Path, TD, fn, mydoc As String
CAJA = Range("G24").Value
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'def = Application.ActivePrinter
If (CAJA <> Empty) Then

ImpresoraAUsar = "CutePDF Writer en CPW2:"
Set ObjNetWork = CreateObject("WScript.Network")
ObjNetWork.SetDefaultPrinter ImpresoraAUsar

'ImpresoraAUsar = "CutePDF Writer"
'On Error GoTo ErrorImpresora
'Set ObjNetWork = CreateObject("WScript.Network")


TD = Format(Date, "ddmmyyyy")
Path = ThisWorkbook.Path & "\"
fn = ActiveSheet.Name
mydoc = Path & fn & ".pdf"
Dest = Cells(3, "E")
Sheets(fn).Range("A1:N31").Copy

Workbooks.Add
Cells(1, 1).PasteSpecial xlPasteValues
Cells(1, 1).PasteSpecial xlPasteFormats
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        mydoc, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False, Orientation:=xlLandscape
        
ActiveWorkbook.Close False

Set OA = CreateObject("Outlook.Application")
Set OM = OA.CreateItem(0)
With OM
    .To = ""
    
    '.CC = ""
    .BCC = ""
    .Subject = "Reporte  "
    .Body = "Informacion del " & fn & " dia " & TD & ""
    .Attachments.Add mydoc
    .Send
End With
If Err.Number = 0 Then
       SendMail_Gmail = True
       MsgBox "REPORTE ENVIADO", vbInformation, "INFO"
Else
       MsgBox "Se produjo el siguiente error: " & Err.Description, vbCritical, "Error nro " & Err.Number
End If
Kill mydoc
Set OM = Nothing
Set OA = Nothing
Set ObjNetWork = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
'Set ObjNetWork = CreateObject("WScript.Network")

'ImpresoraAUsar = "LR2000"
'ObjNetWork.SetDefaultPrinter ImpresoraAUsar
'Set ObjNetWork = CreateObject("WScript.Network")
'ObjNetWork.SetDefaultPrinter ImpresoraAUsar
Impresora = "POS-80 en LPT1:"
Set ObjNetWork = CreateObject("WScript.Network")
ObjNetWork.SetDefaultPrinter Impresora

Exit Sub

ErrorImpresora:
MsgBox "La impresora NO existe" & vbNewLine & "Por favor verifique la existencia" & vbNewLine & ImpresoraAUsar

Else
MsgBox "DEBE LLENAR EL VALOR DE LA CAJA ANTES DE ENVIAR EL REPORTE ", vbInformation, "INFO"


End If
End Sub
